package com.dongdongshop.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dongdongshop.data.Result;
import com.dongdongshop.data.ResultEnum;
import com.dongdongshop.pojo.seller.TbContent;
import com.dongdongshop.service.ContentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("content")
public class ContentController {

    private final Logger logger= LoggerFactory.getLogger(ContentController.class);

    @Reference
    private ContentService contentService;

    @RequestMapping("index")
    public String index(){
        return "index";
    }

    //天气预报

    //轮播图
    @RequestMapping("findCarouselAll")
    @ResponseBody
    public Result findCarouselAll(){
        try {
            List<TbContent> list=contentService.findCarouselAll();
            logger.info("查询方法");
            return Result.response(ResultEnum.OK).setData(list);
        }catch (Exception e){
            logger.info("数据查询失败",e);
            return Result.response(ResultEnum.FAIL);
        }
    }

    //今日推荐
    @RequestMapping("findRecommendAll")
    @ResponseBody
    public Result findRecommendAll(){
        try {
            List<TbContent> list=contentService.findRecommendAll();
            logger.info("查询方法");
            return Result.response(ResultEnum.OK).setData(list);
        }catch (Exception e){
            logger.info("数据查询失败",e);
            return Result.response(ResultEnum.FAIL);
        }
    }
    //猜喜欢
    @RequestMapping("findLikeAll")
    @ResponseBody
    public Result findLikeAll(){
        try {
            List<TbContent> list=contentService.findLikeAll();
            logger.info("查询方法");
            return Result.response(ResultEnum.OK).setData(list);
        }catch (Exception e){
            logger.info("数据查询失败",e);
            return Result.response(ResultEnum.FAIL);
        }
    }
    //有趣
    @RequestMapping("findAmusingAll")
    @ResponseBody
    public Result findAmusingAll(){
        try {
            List<TbContent> list=contentService.findAmusingAll();
            logger.info("查询方法");
            return Result.response(ResultEnum.OK).setData(list);
        }catch (Exception e){
            logger.info("数据查询失败",e);
            return Result.response(ResultEnum.FAIL);
        }
    }
}
